const express = require('express')
const router = express.Router()
const path = require('path')
const jsonfile = require('jsonfile')


router.post('/', async (req, res) => {
  const file = path.join(__dirname, '../../public/files/json/motto.json')
  jsonfile.readFile(file)
    .then(obj => {
      let data = {motto: obj.motto, mottoRef: obj.mottoRef}
      res.send({
        code: 0,
        msg: '获取今日经典成功',
        data
      })
    })
    .catch(error => {
      console.error(error)
      res.send({
        code: 1,
        msg: error
      })
    })  
})

module.exports = router